<template>
  <div class="register-box">
    <div class="logo-wrap">
      <!-- 页面logo -->
      <img class="logo" src="https://img.alicdn.com/tfs/TB1sJWbjhv1gK0jSZFFXXb0sXXa-312-60.png" />
    </div>
    <div class="input-tel-wrap">
      <!-- 手机号框 -->
      <input
        v-model="userLogin.phone"
        name="fm-sms-login-id"
        type="tel"
        class="fm-text"
        placeholder="请输入您的手机号"
      />
    </div>
    <div class="input-pwd-wrap">
      <!-- 密码框 -->
      <input
        v-model="userLogin.password"
        name="fm-smscode"
        type="text"
        class="fm-text"
        placeholder="请输入您的密码"
      />
    </div>
    <div class="fm-btn">
      <!-- 登录按钮 -->
      <button @click="goToLogin" type="submit" tabindex="3" class="fm-button fm-submit sms-login">登录</button>
    </div>
    <div class="new-user">
      <!-- 跳转到注册页 -->
      <a @click="gotoRegister">新用户注册</a>
    </div>
    <!-- 其他的登录方式 暂时未完善 期待后续 -->
    <div class="other-login-wrap">
      <div class="other-login">
        <div class="other-login-h" @click="showClick">
          <span style="margin-right: 6px;">其他登录方式</span>
          <img
            class="other-login-icon"
            src="//kaola-haitao.oss.kaolacdn.com/976c8d7b-c2e2-4108-abfe-765d48a25a36_28_28.png"
            alt="收缩展开"
          />
        </div>
        <ul class="other-login-way" v-show="isshow">
          <li @click="otherClick">
            <img
              src="//kaola-haitao.oss.kaolacdn.com/e491c1e7-7849-4d58-b967-2c896ec8f2f6_72_72.png"
              alt="淘宝"
            />
          </li>
          <li @click="otherClick">
            <img
              src="//kaola-haitao.oss.kaolacdn.com/c069d541-f233-42a5-9d6c-e44f63e8939f_72_72.png"
              alt="微博"
            />
          </li>
          <li @click="otherClick">
            <img
              src="//kaola-haitao.oss.kaolacdn.com/9dedbeef-c3e7-4d73-920b-a49af654036c_72_72.png"
              alt="邮箱"
            />
          </li>
        </ul>
      </div>
    </div>
    <!-- 底部提示 -->
    <div class="bottom">
      注册/登录即代表同意
      <a
        class="bottom-link"
        href="//you.kaola.com/common/page.html?key=Privacy_policy&hideNav=1"
      >隐私政策</a>
      和
      <a
        class="bottom-link"
        href="//terms.alicdn.com/legal-agreement/terms/suit_bu1_other/suit_bu1_other202003231515_29928.html"
      >服务政策</a>
    </div>
  </div>
</template>

<script>
// 引入vant
import Vue from "vue";
import { Toast } from "vant";
Vue.use(Toast);

export default {
  data() {
    return {
      isshow: false,
      userLogin: {
        phone: "",
        password: "",
      },
    };
  },
  created() {
    // 导航栏底部隐藏
    this.$bus.$emit("FooterBar", false);
  },
  mounted() {},
  methods: {
    otherClick() {
      Toast.fail("不好意思哦，正在努力实现ing！");
    },
    // 登录功能实现及前端校验
    goToLogin() {
      if (this.userLogin.phone == "" || this.userLogin.password == "") {
        Toast.fail("账号或密码不能为空！");
        return;
      }
      console.log(this.userLogin);
      this.$axios.post("/admin/login", this.userLogin).then((ret) => {
        // console.log("成功");
        var token = ret.data.data.token;
        localStorage.setItem("isLogin", token);
        localStorage.setItem("user", ret.config.data);
        Toast.success("登录成功！");
        setTimeout(() => {
          this.$router.push("/cart");
        }, 1000);
      });
    },
    showClick() {
      this.isshow = !this.isshow;
    },
    gotoRegister() {
      this.$router.push("/register");
    },
  },
};
</script>

<style scoped>
* {
  margin: 0;
  padding: 0;
  outline: none;
}
.logo-wrap {
  box-sizing: border-box;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  cursor: default;
  height: 80px;
  line-height: 80px;
  position: relative;
  height: 67px;
  line-height: 67px;
  overflow: hidden;
  -webkit-transition: height 0.4s;
  transition: height 0.4s;
  text-align: center;
  margin: 10px 12px 0;
}
.logo {
  margin: 0 auto;
  height: 30px;
  margin-top: 5px;
  vertical-align: middle;
}
.input-tel-wrap .input-pwd-wrap {
  font: 400 12px arial;
  color: rgb(221, 219, 219);
  margin-bottom: 12px;
  position: relative;
  box-sizing: border-box;
  margin: 20px;
  font-size: 14px;
  /* margin-bottom: 12px; */
  padding: 12px 10px 12px 10px;
}
.fm-text {
  border-radius: 21px;
  height: 42px;
  line-height: 20px;
  background-color: #f5f5f5;
  border: 1px solid #f5f5f5;
  padding-left: 10px;
  width: 90%;
  outline: none;
  font-size: 14px;
  margin: 1% 0px 8px 3%;
}
.fm-btn {
  box-sizing: border-box;
  margin: 0;
  /* padding:  0px 0px 0px 10px; */
}
.fm-button {
  height: 42px;
  line-height: 42px;
  background-image: linear-gradient(-90deg, #f00 0, #ff3264 100%);
  border: 0;
  border-radius: 21px;
  font-size: 16px;
  background-color: #ff9000;
  /* outline: none; */
  color: #fff;
  cursor: pointer;
  width: 92%;
  margin: 1% 0px 8px 3%;
  margin-top: 20px;
}
.new-user {
  /* margin: 8px 0;
  text-align: right;
  zoom: 1;
  box-sizing: border-box;
  padding: 0;
  display: block; */
  float: right;
  font-size: 12px;
  color: #999;
  margin-right: 30px;
}
/* .new-user-in {
  height: 14px;
  line-height: 14px;
  color: #999;
  margin-left: 0;
  font-size: 12px;
  display: inline-block;
  text-decoration: none;
  margin: 8px 30px 0 8px;
  text-align: right;
  zoom: 1;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  cursor: pointer;
} */
.other-login-warp {
  margin: 0;
  padding: 0;
  outline: none;
  color: #333;
}
.other-login {
  /* box-sizing: border-box;
  text-size-adjust: 100%; */
  text-align: center;
  height: 16px;
  line-height: 16px;
  font-size: 14px;
  color: #666;
  letter-spacing: 1px;
  margin-top: 100px;
}
.other-login-icon {
  width: 14px;
  height: 14px;
  vertical-align: -15%;
}
.other-login-h {
  letter-spacing: 1px;
  font-family: Helvetica;
  display: flex;
  justify-content: center;
}
.other-login-way {
  margin-top: 18px;
  text-align: center;
  display: flex;
  justify-content: center;
  list-style-type: disc;
  margin-block-start: 1em;
  margin-block-end: 1em;
  margin-inline-start: 0px;
  margin-inline-end: 0px;
  padding-inline-start: 20px;
}
.other-login-way > li {
  display: inline;
  margin-right: 21px;
}
.other-login-way > li > img {
  height: 36px;
  width: 36px;
}
/* .other-login-title {
  text-align: center;
  height: 16px;
  line-height: 16px;
  box-sizing: border-box;
  text-size-adjust: 100%;
}
.other-login-title > img {
  width: 14px;
  height: 14px;
  vertical-align: -15%;
  border: 0;
  transform: rotate(180deg);
}
.other-login-way {
  margin-top: 18px;
  text-align: center;
  display: block;
  list-style-type: disc;
  margin-block-start: 1em;
  margin-block-end: 1em;
  margin-inline-start: 0px;
  margin-inline-end: 0px;
  padding-inline-start: 40px;
}
.other-login-way > li {
  display: inline;
  margin-right: 21px;
  list-style: none;
  text-align: -webkit-match-parent;
} */
.bottom {
  /* position: absolute;
  bottom: 30px;
  width: 100%;
  text-align: center;
  font-size: 12px;
  color: #999; */
  position: absolute;
  bottom: 60px;
  width: 100%;
  text-align: center;
  font-size: 12px;
  color: #999;
}
.bottom > a {
  color: #999;
}
</style>
